/* rcsoisa2.p - Update ABS Work File with Consignment Data                  */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.             */
/* $Revision: 1.5 $                               */

/****************************************************************************/
/* DESCRIPTION: This program updates the shipper work file with consigment  */
/*              data.                                                       */
/****************************************************************************/

/* $Revision: 1.5 $    BY: Patrick Rowan  DATE: 04/04/02  ECO: *P00F* */

/*V8:ConvertMode=NoConvert                                                  */

/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*         THIS PROGRAM IS A BOLT-ON TO STANDARD PRODUCT MFG/PRO.           */
/* ANY CHANGES TO THIS PROGRAM MUST BE PLACED ON A SEPARATE ECO THAN        */
/* STANDARD PRODUCT CHANGES.  FAILURE TO DO THIS CAUSES THE BOLT-ON CODE TO */
/* BE COMBINED WITH STANDARD PRODUCT AND RESULTS IN PATCH DELIVERY FAILURES.*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */

{mfdeclre.i}

/* VARIABLES */
define variable consign_inv_acct as character no-undo.
define variable consign_inv_sub  as character no-undo.
define variable consign_inv_cc as character no-undo.
define variable consign_intrans_acct as character no-undo.
define variable consign_intrans_sub  as character no-undo.
define variable consign_intrans_cc as character no-undo.
define variable consign_offset_acct as character no-undo.
define variable consign_offset_sub  as character no-undo.
define variable consign_offset_cc as character no-undo.

/* Include files for Consignment variables and ROPs*/
{pxsevcon.i}
{socnvars.i}
{socnsod.i}

/*Include for work_abs_mstr variables */
{rcwabsdf.i}

for each work_abs_mstr
   fields (abs_order abs_line)
   where abs_id begins "i"
   exclusive-lock:

   run disposeSalesOrderDetailBuffer
      (buffer bSalesOrderDetail).
   run createSalesOrderDetailBuffer
      (buffer bSalesOrderDetail).
   assign
      bSalesOrderDetail.sod_nbr     = abs_order
      bSalesOrderDetail.sod_line   = integer(abs_line).


   run readSalesOrderDetailConsignRecord
            (buffer bSalesOrderDetail,
             input {&NO_LOCK_FLAG},
             input {&WAIT_FLAG}).

   assign
      abs_consign_flag     = bSalesOrderDetail.sod_consignment
      abs_max_aging_days   = bSalesOrderDetail.sod_max_aging_days
      abs_transfer_to_loc  =
          (if bSalesOrderDetail.sod_intrans_loc <> ""
                         then
                             bSalesOrderDetail.sod_intrans_loc
                         else
                             bSalesOrderDetail.sod_consign_loc)
      abs_translt_days     = bSalesOrderDetail.sod_translt_days
      abs_auto_replenish   = bSalesOrderDetail.sod_auto_replenish.


   /*GET THE ACCOUNTS FOR INTRANS-IT OR CONSIGNMENT LOCATION */

   {gprun.i ""socnacct.p""
            "(input abs_item,
              input abs_site,
              input abs_transfer_to_loc,
              output consign_inv_acct,
              output consign_inv_sub,
              output consign_inv_cc,
              output consign_intrans_acct,
              output consign_intrans_sub,
              output consign_intrans_cc,
              output consign_offset_acct,
              output consign_offset_sub,
              output consign_offset_cc)"}


   /*SET THE ACCOUNTS BASED ON INTRANS-IT OR CONSIGNMENT */

   assign
      abs_consign_dr_acct =
          (if bSalesOrderDetail.sod_intrans_loc <> ""
                            then
                               consign_intrans_acct
                            else
                               consign_inv_acct)
      abs_consign_dr_sub  =
          (if bSalesOrderDetail.sod_intrans_loc <> ""
                            then
                               consign_intrans_sub
                            else
                               consign_inv_sub)
      abs_consign_dr_cc =
          (if bSalesOrderDetail.sod_intrans_loc <> ""
                               then
                               consign_intrans_cc
                            else
                               consign_inv_cc)
      abs_consign_cr_acct = consign_offset_acct
      abs_consign_cr_sub  = consign_offset_sub
      abs_consign_cr_cc   = consign_offset_cc.

end.  /* for each work_abs_mstr */
